//
// Description: 4. 多重背包问题 I
// Created by Loading on 2022/6/1.
//

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 110;

int v[N], w[N], s[N];
int dp[N][N];

int main() {
    int n, V;
    cin >> n >> V;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i] >> w[i] >> s[i];
    }

    // 朴素版，O(n^3) 此数据范围可以AC
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= V; ++j) {
            for (int k = 0; k <= j / v[i] && k <= s[i]; ++k) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - k * v[i]] + k * w[i]);
            }
        }
    }

    cout << dp[n][V] << endl;

    return 0;
}